www.gusucode.com > matlab编程NSCT分解 图像融合 各个融合指标评价体系 分解源码程序 > matlab编程NSCT分解 图像融合 各个融合指标评价体系 分解源码程序/NSCT/nsctfunction.m

    function imrec=nsctfunction(im,I);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Image decomposition by nonsubsampled contourlet transform (NSSC).
% This is the iterated filter bank that computes the nonsubsampled
% contourlet transform.  
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Parameteters:
nlevels = 4 ;        % Decomposition level
%pfilter = 'pkva' ;              % Pyramidal filter
dfilter = 'dmaxflat7'; %'cd' ;              % Directional filter
pfiltr= '9-7';
disp( nlevels); disp(dfilter);disp(pfiltr);
% Nonsubsampled Contourlet decomposition
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%SAR图像分解
im=(im-mean(im(:)))*std(I(:))/std(im(:)) + mean(I(:));

coeffsar = nsctdec( double(im), nlevels ,dfilter,pfiltr);
sarlow=coeffsar{1};
sarhigh=coeffsar{2};

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%可见光图像分解

A=im2double(I);
coeffvisible = nsctdec( double(A), nlevels ,dfilter,pfiltr);
visiblelow=coeffvisible{1};
visiblehigh=coeffvisible{2};

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%融合规则:低频采用加权平均法,高频采用绝对值较大法

[m,n,s]=size(visiblehigh{1})
hp=cell(1,16);
for  i= 1 :16
    for row=1:m
    for cloms=1:n
        if sarhigh{i}(row,cloms) >= visiblehigh{i}(row,cloms)
            hp{i}(row,cloms)=sarhigh{i}(row,cloms);
        else
            hp{i}(row,cloms)=visiblehigh{i}(row,cloms);
        end
    end
    end
end
   
a=0.6;
b=0.3;
lp=a.*(sarlow+visiblelow)+b.*(sarlow-visiblelow);


coeffs=cell(1,2);
coeffs{1}=lp;
coeffs{2}=hp;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Nonsubsampled Contourlet transform (NSSC) reconstruction.
% This is the inverse of nsscdec, i.e.
% imrec = nsscrec(coeffs, dfilter, pfilter);
% would reconstruct imrec = im
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Reconstruct image
imrec = nsctrec( coeffs, dfilter, pfiltr ) ;


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %产生融合图像
% for i=1:3
%     F(:,:,i)=imvisible(:,:,i)+(im-imrec);
% end



% % Show the reconstruction image and the original image
% %if 0
% figure;
% subplot(1,2,1), imagesc( im, [0, 255] ); 
% title('Original image' ) ;
% colormap(gray);
% axis image off;
% subplot(1,2,2), imagesc( imrec, [0, 255] );
% title('Reconstructed image' ) ;
% colormap(gray);
% axis image off;
% %end
% 
% mse = sum( sum( (imrec - double(im)).^2 ) );
% mse = mse / prod(size(im));
% 
% disp( sprintf('The mean square error is: %f', mse ) );
% disp(' ');